package com.ticorp.framework.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ticorp.framework.service.BapiExecutionService;
import com.ticorp.framework.service.ConstantsTableService;
import com.ticorp.salmofood.common.Constantes;

/**
 * 
 * Implementacion de BapiExecutionService. Utiliza un properties para su
 * inicializacion.
 * 
 * @author wpereyrac
 * 		   Nestor Audante
 */

public class ConstantsTableServiceImpl implements ConstantsTableService {
	
	private BapiExecutionService bapiExecutionService;
	
	public ConstantsTableServiceImpl(){		
	}

	/*
	 * (non-Javadoc)
	 * @see com.ticorp.framework.service.ConstantsTableService#getConstantsTable(java.lang.String)
	 */
	public List getConstantsTable(String tableName){
		Map importMap = new HashMap();
		Map map = new HashMap();
		map.put("MAESTRO", tableName);
		List it_maestros = new ArrayList();
		it_maestros.add(map);
		importMap.put("IT_MAESTROS", it_maestros);
		return bapiExecutionService.getTableAsList("Z_BAPI_MC_CLIENTES", importMap, "IT_MATCHCODE");
	}
	
	/*
	 * (non-Javadoc)
	 * @see com.ticorp.framework.service.ConstantsTableService#getConstantsTable2(java.lang.String, java.lang.String)
	 */
	public List getConstantsTable(String tableName, String tipoSolicitud){
		Map importMap = new HashMap();
		Map map = new HashMap();		
		map.put("MAESTRO", tableName);
		List it_maestros = new ArrayList();
		it_maestros.add(map);
		
		List it_filtro = new ArrayList();
		
		if(!tipoSolicitud.equals("")){
			Map m = new HashMap();
			m.put("FIELDNM", "TIPO");
			m.put("LOW", tipoSolicitud);
			it_filtro.add(m);
		}
		
		importMap.put("IT_FILTROS", it_filtro);
		importMap.put("P_MAESTRO", tableName);
		importMap.put("P_BUKRS", Constantes.BUKRS);
		importMap.put("IT_MAESTROS", it_maestros);
		return bapiExecutionService.getTableAsList("Z_BAPI_ST_MC_CONTRATOS", importMap,  "IT_MATCHCODE");
	}
	
	
	
	public void setBapiExecutionService(BapiExecutionService bapiExecutionService) {
		this.bapiExecutionService = bapiExecutionService;
	}
	


}